//------------------------------------------------------------------------------
//
// Motion Recorder for Lynx 6 Arm
//
// Written Nov-2007 by Trevor Taylor, Software Technology, Australia
//
//------------------------------------------------------------------------------

using Microsoft.Ccr.Core;
using Microsoft.Dss.Core.Attributes;
using Microsoft.Dss.ServiceModel.Dssp;
using System;
using System.Collections.Generic;
using W3C.Soap;
using motionrecorder = ProMRDS.Robotics.MotionRecorder;


namespace ProMRDS.Robotics.MotionRecorder
{
    
    /// <summary>
    /// MotionRecorder Contract class
    /// </summary>
    public sealed class Contract
    {
        /// <summary>
        /// The Dss Service contract
        /// </summary>
        public const String Identifier = "http://www.promrds.com/contracts/2007/11/motionrecorder.html";
    }
    /// <summary>
    /// The MotionRecorder State
    /// </summary>
    [DataContract()]
    public class MotionRecorderState
    {

    }

    /// <summary>
    /// MotionRecorder Main Operations Port
    /// </summary>
    [ServicePort()]
    public class MotionRecorderOperations : PortSet<DsspDefaultLookup, DsspDefaultDrop, Get>
    {
    }
    /// <summary>
    /// MotionRecorder Get Operation
    /// </summary>
    public class Get : Get<GetRequestType, PortSet<MotionRecorderState, Fault>>
    {
        /// <summary>
        /// MotionRecorder Get Operation
        /// </summary>
        public Get()
        {
        }
        /// <summary>
        /// MotionRecorder Get Operation
        /// </summary>
        public Get(Microsoft.Dss.ServiceModel.Dssp.GetRequestType body) : 
                base(body)
        {
        }
        /// <summary>
        /// MotionRecorder Get Operation
        /// </summary>
        public Get(Microsoft.Dss.ServiceModel.Dssp.GetRequestType body, Microsoft.Ccr.Core.PortSet<MotionRecorderState,W3C.Soap.Fault> responsePort) : 
                base(body, responsePort)
        {
        }
    }

    #region WinForms Communication

    public class FromWinformEvents : Port<FromWinformMsg>
    {
    }

    public class FromWinformMsg
    {
        public enum MsgEnum
        {
            Loaded,
            Start,
            Exit,
            Reset,
            Park,
            MoveJoint,
            MoveMultipleJoints,
            MoveToPosition,
            GetPose,
            SetPose,
            Test
        }

        private string[] _parameters;
        public string[] Parameters
        {
            get { return _parameters; }
            set { _parameters = value; }
        }

        private MsgEnum _command;
        public MsgEnum Command
        {
            get { return _command; }
            set { _command = value; }
        }

        private object _object;
        public object Object
        {
            get { return _object; }
            set { _object = value; }
        }

        public FromWinformMsg(MsgEnum command, string[] parameters)
        {
            _command = command;
            _parameters = parameters;
        }
        public FromWinformMsg(MsgEnum command, string[] parameters, object objectParam)
        {
            _command = command;
            _parameters = parameters;
            _object = objectParam;
        }
    }

    // Object for moving a single joint
    public class MoveJointParameters
    {
        public double Angle;
        public string Name;
        public MoveJointParameters(string name, float angle)
        {
            Angle = angle;
            Name = name;
        }
    }

    // Object for moving multiple joints
    public class MoveMultipleJointParameters
    {
        public float[] Angles;
        public string[] Names;
        public MoveMultipleJointParameters(string[] names, float[] angles)
        {
            Angles = angles;
            Names = names;
        }
    }

    // Object for moving to a pose
    public class MoveToPositionParameters
    {
        public float X;
        public float Y;
        public float Z;
        public float GripAngle;
        public float GripRotation;
        public float Grip;
        public float Time;
    }

    #endregion

}
